<?php
/**
 * Created by IntelliJ IDEA.
 * User: skyADMIN
 * Date: 15/9/13
 * Time: 下午10:40
 */
require_once ('connect.php');

$action = $_GET['action'];
if($action == 'register'){
    $user = stripslashes(trim($_POST['user']));
    $pass = stripslashes(trim($_POST['pass']));
    if (empty ($user)) {
        echo '用户名不能为空';
        exit;
    }
    if (empty ($pass)) {
        echo '密码不能为空';
        exit;
    }
    $sql = "select * from login WHERE username='$user'";
    $f_query = mysql_query($sql);
    //echo $sql;
    if(mysql_num_rows($f_query)!=0){
        echo 0;
        exit;
    }
    $md5pass = md5($pass);
    $query = mysql_query("INSERT INTO login(username, password) VALUES ('$user','$md5pass')");
    //$result = mysql_query($query);
    echo 1;
}
?>